﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Server.Kestrel.Core;

namespace IdentityMiddleware
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) 

        {
            var env=Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
            if (env=="Development")
            {
                return WebHost.CreateDefaultBuilder(args)
                    .UseStartup<Startup>().UseKestrel((context, options) =>
                    {
                        options.Listen(IPAddress.Any, 5005, listenOptions =>
                        {
                            listenOptions.UseHttps("Test.pfx", "81700214");
                        });
                    })/*.UseUrls("http://*:5006")*/;
            }
            else
            {
                return WebHost.CreateDefaultBuilder(args)
                    .UseStartup<Startup>();/*.UseUrls("http://*:5006")*/;
            }

            
        }
    }
}
